﻿@{
    ViewBag.Title = "IndexSelfInfo";
}
@*@model PagedList<SelfInfo.Models.SELFINFO>*@
@model MVCPager.MVCPagerModel<SelfInfo.Models.SELFINFO> 
<h2>Index SelfInfo</h2>

<div class='row'>
<div class="col-lg-3">
    <div class="input-group">
      <input type="text" class="form-control" id='txtPieceName'>
      <span class="input-group-btn">
        <button class="btn btn-default" type="button" id='btnSearch'>SEARCH!</button>
        <button class="btn btn-primary" type="button" id='btnReset'>RESET</button>
      </span>
    </div><!-- /input-group -->
  </div>
</div>

<div class='row'>
<div class="col-lg-7">
<table class="table table-striped">
   <thead>
      <tr>
         <td>ID</td>
         <td>PIECEID</td>
         <td>DATE</td>
         <td>SCORE</td>
         <td>BRIEF</td>
         <td>COMMENT</td>
      </tr>
   </thead>
   <tbody>
    @foreach (var item in Model.info) {
    <tr>
        <td>  
            @Html.DisplayFor(modelItem => item.ID)
        </td>
        <td>
            @Html.ActionLink(item.PIECE.NAME, "Index", new { pieceid = item.PIECE.ID })
            @*@Html.DisplayFor(modelItem => item.PIECE.NAME)*@
        </td>
        <td>
            @item.TODAY.ToString("yyyy-MM-dd")
        </td>
       
         <td>
            @Html.DisplayFor(modelItem => item.SCORE)
        </td>

        <td>
            @Html.DisplayFor(modelItem => item.BRIEF)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.COMMENT)
        </td>
       
        <td>
            <a id='model_create' data-toggle="modal" data-target="#view_create" href="/selfinfo/selfinfo/edit/@item.ID">Edit</a>
            @* @Html.ActionLink("Edit", "Edit", new { id = item.ID }) *@
            |
             <a id='model_delete' data-toggle="modal" data-target="#view_delete" data-id="@item.ID">Delete</a>
            @*<a class='btnDel' data-id='@item.ID' href='javascript:void(0)'>Delete</a>*@
            @*@Html.ActionLink("Delete", "Delete", new { id = item.ID })*@ 
        </td>
    </tr>
    }
   </tbody>

</table>
</div>
</div>

<div class="row">
<div class="col-lg-7">
   @Url.Pager("SelfInfo", "Index", Model.PageSize, Model.PageIndex, Model.RecordCount, "pagination")
</div>


@*pager插件一*@
@*<div class="col-lg-7">
 @Html.Pager(Model, new PagerOptions
 {
     PageIndexParameterName = "id",
     ShowPageIndexBox = true,
     FirstPageText = "FIRST",
     PrevPageText = "PREV",
     NextPageText = "NEXT",
     LastPageText = "LAST",
     PageIndexBoxType = PageIndexBoxType.TextBox,
     PageIndexBoxWrapperFormatString = "NUM{0}",
     GoButtonText = "TO"
 })
 
 共有 @Model.TotalItemCount 篇留言 @Model.CurrentPageIndex/@Model.TotalPageCount
</div>*@
</div>   

<div class='row'>
<div class="col-lg-7">
@* @Html.ActionLink("Create One", "Create", new { }, new { @class = "btn btn-primary  pull-left" })*@
<a id='model_create' class="btn btn-primary" data-toggle="modal" data-target="#view_create" href="/selfinfo/selfinfo/create">Create One</a>
</div>
</div>

<div  class="modal fade" id="view_create" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
 <div class="modal-dialog">
    <div class="modal-content"> 
      <div class='modal-body'>
      </div>
    </div>
 </div>
</div>

<div id="view_delete" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
        <a href="#" data-dismiss="modal" aria-hidden="true" class="close">×</a>
         <h3>Delete</h3>
    </div>
    <div class="modal-body">
        <p>You are about to delete!</p>
        <p>Do you want to proceed?</p>
    </div>
    <div class="modal-footer">
      <a href="#" id="btnYes" class="btn danger">Yes</a>
      <a href="#" data-dismiss="modal" aria-hidden="true" class="btn secondary">No</a>
    </div>
</div>
</div>
</div>


    <script>
        $(document).ready(function () {
            $('#view_delete').on('show.bs.modal', function (e) {
                var id = $(e.relatedTarget).data('id'),
                removeBtn = $(this).find('.danger');
                removeBtn.data('id', id);

            })
            $('#btnYes').click(function () {
                var id = $(this).data('id');
                $.get('/SelfInfo/SelfInfo/Delete/' + id, function (data) {
                    if (data) {
                        alert("Success");
                        window.location = '/SelfInfo/SelfInfo/Index';
                    }
                });
            });

            $('#btnSearch').click(function () {
                var piecename = $('#txtPieceName').val();
                window.location = '/SelfInfo/SelfInfo/Index?piecename=' + piecename;
            });

            $('#btnReset').click(function () {           
                window.location = '/SelfInfo/SelfInfo/Index';
            });
        });
    
    </script>


